import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/home/index.vue'
import Station from '../views/station/index.vue'
import Ask from '../views/ask/index.vue'
import User from '../views/user/index.vue'
import Search from '../components/home/search/search.vue'
import Safe from '../components/user/safe.vue'
import Modify from '../components/user/modify.vue'
import Article from '../components/user/myArticle.vue'
import Release from '../components/user/release.vue'
import myAsk from '../components/user/myask.vue'
import userInfo from '../components/user/userinfo.vue'
import StationAuth from '../components/user/stationauth.vue'
import HouseAuth from '../components/user/houseauth.vue'
import ArticleDetail from '../components/articledetail.vue'
import Classify from '../components/classify/index.vue'
import Askdetail from '../views/ask/askdetail.vue'

Vue.use(VueRouter)

const routes = [{ //首页
		path: '/',
		name: 'home',
		component: Home
	},
	{ //选站
		path: '/station',
		name: 'station',
		component: Station
	},
	{ //问问
		path: '/ask',
		name: 'ask',
		component: Ask
	},
	{ //我的
		path: '/user',
		name: 'user',
		component: User
	},
	{ //搜索
		path: '/search',
		name: 'search',
		component: Search
	},
	{ //我的二级
		path: '/safe',
		name: 'safe',
		component: Safe
	},
	{ //修改手机号
		path: '/modify',
		name: 'modify',
		component: Modify,
		children: [{ //修改手机号
				path: "/",
				component: () => import('../components/user/mobile.vue'),
				name: 'mobile'
			},
			{ //修改密码
				path: "password",
				component: () => import('../components/user/password.vue'),
				name: 'password'
			}
		]
	},
	{ //我的文章列表
		path: '/articleList',
		name: 'articleList',
		component: Article
	},
	{ //发布文章
		path: '/release',
		name: 'release',
		component: Release
	},
	{ //我的提问
		path: '/myask',
		name: 'myask',
		component: myAsk
	},
	{ //个人资料
		path: '/userinfo',
		name: 'useronfo',
		component: userInfo

	},
	{ //站长认证
		path: '/stationauth',
		name: 'stationauth',
		component: StationAuth

	},
	{ //房产认证
		path: '/houseauth',
		name: 'houseauth',
		component: HouseAuth

	},
	{ //文章详情
		path: '/articledetail',
		name: 'articledetail',
		component: ArticleDetail

	},
	{ //问题详情
		path: '/askdetail',
		name: 'askdetail',
		component: Askdetail

	},
	{ //二级分类
		path: '/classify',
		name: 'classify',
		component: Classify,
		children: [{ //无数据
				path: "/",
				component: () => import('../components/classify/nodata.vue'),
				name: 'noData'
			},
			{ //详情页
				path: "detail",
				component: () => import('../components/classify/detail.vue'),
				name: 'Detail',
				meta: {
					keepAlive: true // true 表示需要使用缓存
				}
			},
			{ //文章列表
				path: "datalist",
				component: () => import('../components/classify/datalist.vue'),
				name: 'datalist',
				meta: {
					keepAlive: true // true 表示需要使用缓存
				}
			},
			{ //留言
				path: "message",
				component: () => import('../components/classify/message.vue'),
				name: 'message',
				meta: {
					keepAlive: true // true 表示需要使用缓存
				}
			},
			{ //举报
				path: "report",
				component: () => import('../components/classify/report.vue'),
				name: 'report',
				meta: {
					keepAlive: true // true 表示需要使用缓存
				}
			},
			{ //服务公告
				path: "servenotice",
				component: () => import('../components/classify/servenotice.vue'),
				name: 'servenotice',
				meta: {
					keepAlive: true // true 表示需要使用缓存
				}
			},
			{ //投票
				path: "vote",
				component: () => import('../components/classify/vote.vue'),
				name: 'vote',
				meta: {
					keepAlive: true // true 表示需要使用缓存
				}
			},
			{ //投票竞选详情
				path: "votedetail",
				component: () => import('../components/classify/votedetail.vue'),
				name: 'votedetail',
				meta: {
					keepAlive: true // true 表示需要使用缓存
				}
			},
			{ //投票活动详情
				path: "voteactivity",
				component: () => import('../components/classify/voteactivity.vue'),
				name: 'voteactivity',
				meta: {
					keepAlive: true // true 表示需要使用缓存
				}
			},
			{ //评议列表
				path: "deliberate",
				component: () => import('../components/classify/deliberate.vue'),
				name: 'deliberate',
				meta: {
					keepAlive: true // true 表示需要使用缓存
				}
			},
			{ //征集列表
				path: "solicitation",
				component: () => import('../components/classify/solicitation.vue'),
				name: 'solicitation',
				meta: {
					keepAlive: true // true 表示需要使用缓存
				}
			},
			{ //征集详情
				path: "solicitationDetail",
				component: () => import('../components/classify/solicitationDetail.vue'),
				name: 'solicitationDetail',
				meta: {
					keepAlive: true // true 表示需要使用缓存
				}
			},
			{ //评议详情
				path: "deliberatedetail",
				component: () => import('../components/classify/deliberatedetail.vue'),
				name: 'deliberatedetail',
				meta: {
					keepAlive: true // true 表示需要使用缓存
				}
			},
			{ //问问列表
				path: "asklist",
				component: () => import('../components/classify/asklist.vue'),
				name: 'asklist',
				meta: {
					keepAlive: true // true 表示需要使用缓存
				}
			},
			{ //提出问题
				path: "asking",
				component: () => import('../components/classify/asking.vue'),
				name: 'asking',
				meta: {
					keepAlive: true // true 表示需要使用缓存
				}
			}
		]
	},
	{ //登录
		path: "/login",
		component: () => import('../components/login/login.vue'),
		name: 'login'
	},
	{ //站长注册
		path: "/stationRegister",
		component: () => import('../components/login/stationRegister.vue'),
		name: 'stationRegister'
	},
	{ //用户注册
		path: "/register",
		component: () => import('../components/login/register.vue'),
		name: 'register'
	},
	{ //完善信息
		path: "/complete",
		component: () => import('../components/login/complete.vue'),
		name: 'complete'
	},
	{ //完善信息
		path: "/completeInfo",
		component: () => import('../components/login/completeInfo.vue'),
		name: 'completeInfo'
	},
	{ //注册成功
		path: "/success",
		component: () => import('../components/login/success.vue'),
		name: 'success'
	},
	{ //忘记密码
		path: "/forget",
		component: () => import('../components/login/forget.vue'),
		name: 'forget'
	},
	{ //忘记密码
		path: "/setpwd",
		component: () => import('../components/login/setPwd.vue'),
		name: 'setpwd'
	}

]

const router = new VueRouter({
	routes,
	scrollBehavior(to, from, savedPosition) {

		if (savedPosition) {
			return savedPosition;
		} else {
			return {
				x: 0,
				y: 0
			}
		}


	}
})

const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
	return originalPush.call(this, location).catch(err => err)
}
export default router
